home *** CD-ROM | disk | FTP | other *** search
- Path: news1.intercall.com!usenet
- From: engevar@intercall.com (Steven Ovits)
- Newsgroups: comp.lang.c++
- Subject: Re: main()
- Date: Thu, 18 Apr 1996 20:58:34 GMT
- Organization: Intercall Inc.
- Message-ID: <4l614s$336@news1.intercall.com>
- References: <3174c0dc.7652220@news.flex.com.au> <829766541snz@j-bg.demon.co.uk> <Dq1C8B.3sC@news.hawaii.edu>
- NNTP-Posting-Host: ts3-144.intercall.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- Alvin Nonaka <xea0005@co.honolulu.hi.us> wrote:
-
- >>In article <3174c0dc.7652220@news.flex.com.au>
- >>> I have come across two different ways that 2 different beginners books
- >>> recommend that every program should start. Could someone please tell
- >>> me which one is the "BEST" or proper way?
-
- [snip]
-
- >'main' can't return. Calling 'exit' is better because the call to exit
- >'cleans up' all resource allocations (which you are supposed to handle)
- >left pending in your code.
-
- >The value passed to exit is 'returned' and control passes to the host
- >environment.
-
- Since this is in a C++ group, I'll dispense with C's main().
- From "The C++ Programming Language," 2 ed, Stroustrup, p.485.
-
- The function main() may be defined as
- int main() { /* ... */ }
- or
- int main(int argc, char* argv[]) { /* ... */ }
-
- A return statement in main() has the effect of calling exit()
- with the return value as the argument.
-
-
-